<?php  
class ControllerCommonFooter extends Controller {
	protected function index() {
		$this->language->load('common/footer');
		$this->load->model('tool/seo_url');
		$this->load->helper('image');
// information
		$this->load->model('catalog/information');
		
		$this->data['informations'] = array();

		foreach ($this->model_catalog_information->getInformationss(4) as $result) {
			$first_img = '';
			$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'), $matches);
			if($matches [1]){
			$first_img = $matches [1] [0];
			} else {
			$first_img = "image/no_image.jpg";
			}
      		$this->data['informations'][] = array(
        		'title' 		 => $result['title'],
				'description' => $result['description'],
				'image'     => $first_img,
	    		'href'  		 => $this->model_tool_seo_url->rewrite($this->url->http('information/information&information_id=' . $result['information_id']))
      		);
    	}
// end information

// tintuc
		$this->load->model('catalog/news'); 
		$results = $this->model_catalog_news->tinmoinhat(4);
		$this->data['newss'] = array();

		foreach ($results as $result) {
			$first_img = '';
			$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'), $matches);
			if($matches [1]){
			$first_img = $matches [1] [0];
			} else {
			$first_img = "image/no_image.jpg";
			}
			
			$this->data['newss'][] = array(
				'title' => $result['title'],
				'date_added' => date('h:iA d/m/Y',strtotime($result['date_added'])),
				'description' => $result['description'],
				'image'     => $first_img,
				'href'  => $this->model_tool_seo_url->rewrite($this->url->http('news/news&news_id=' . $result['news_id']))
			);
		}
// end intuc
		$this->data['text_powered_by'] = sprintf($this->language->get('text_powered_by'), date('Y', time()),$this->language->get('text_semer'),$this->language->get('text_arr'));
		$this->data['text_powered'] = $this->language->get('text_powered');
		$this->data['owner'] = $this->config->get('config_owner_' . $this->config->get('config_language_id'));
		$this->data['address'] = $this->config->get('config_address_' . $this->config->get('config_language_id'));
		$this->data['telephone'] = $this->config->get('config_telephone');
		$this->data['fax'] = $this->config->get('config_fax');
		$this->data['hotline'] = $this->config->get('config_hotline');
		$this->data['text_latest_news'] = $this->language->get('text_latest_news');
		$this->data['text_information'] = $this->language->get('text_information');
		
    	$this->data['text_address'] = $this->language->get('text_address');
		$this->data['text_emails'] = $this->language->get('text_emails');
		$this->data['text_hotline'] = $this->language->get('text_hotline');
    	$this->data['text_telephone'] = $this->language->get('text_telephone');
    	$this->data['text_fax'] = $this->language->get('text_fax');
		
		$this->data['text_home'] = $this->language->get('text_home');
		$this->data['text_sitemap'] = $this->language->get('text_sitemap');
		$this->data['text_special'] = $this->language->get('text_special');
		$this->data['text_contact'] = $this->language->get('text_contact');
		$this->data['text_gioithieu'] = $this->language->get('text_gioithieu');
		$this->data['text_news'] = $this->language->get('text_news');
		$this->data['text_dangky'] = $this->language->get('text_dangky');
		$this->data['text_dangnhap'] = $this->language->get('text_dangnhap');
		$this->data['text_information'] = $this->language->get('text_information');
		
		$this->data['special'] = $this->model_tool_seo_url->rewrite($this->url->http('product/special'));
		$this->data['home'] = $this->model_tool_seo_url->rewrite($this->url->http('common/home'));
		$this->data['contact'] = $this->model_tool_seo_url->rewrite($this->url->http('information/contact'));
    	$this->data['sitemap'] = $this->model_tool_seo_url->rewrite($this->url->http('information/sitemap'));
		$this->data['gioithieu'] = $this->model_tool_seo_url->rewrite($this->url->http('information/gioithieu'));
		$this->data['tintuc'] = $this->model_tool_seo_url->rewrite($this->url->http('news/tintuc'));
		$this->data['dangnhap'] = $this->model_tool_seo_url->rewrite($this->url->https('account/login'));
		$this->data['dangky'] = $this->model_tool_seo_url->rewrite($this->url->https('account/create'));
		
		$this->id = 'footer';
		if ($this->config->get('footer_status')) {
			$this->data['footer'] = html_entity_decode($this->config->get('footer_code'), ENT_QUOTES, 'UTF-8');
		} else {
			$this->data['footer'] = '';
		}
		if ($this->config->get('hotkeyword_status')) {
			$this->data['hotkeyword'] = html_entity_decode($this->config->get('hotkeyword_code'), ENT_QUOTES, 'UTF-8');
		} else {
			$this->data['hotkeyword'] = '';
		}
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/footer.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/footer.tpl';
		} else {
			$this->template = 'default/template/common/footer.tpl';
		}
		
		$this->render();
	}
}
?>